package com.woniu.customer.configuration;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqConfiguration {
    //  主题模式
    //  定义两个队列
    @Bean
    public Queue topicmail(){
        return new Queue("verifycode");
    }
    //  定义topics类型交换机
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange("verifyExchange");
    }
    //  绑定交换机，设置路由键
    @Bean
    public Binding bindingqueuemailtotopicExchange(Queue topicmail, TopicExchange topicExchange){
        return BindingBuilder.bind(topicmail).to(topicExchange).with("#.verifymail.#");
    }
}
